home *** CD-ROM | disk | FTP | other *** search
/ 3D Games (Spidla) / 3dhry1.iso / mAz Lite 1.0 / movement.wdl < prev    next >
Encoding:
Text File  |  2003-03-17  |  9.4 KB  |  323 lines

  1. // Template file v5.202 (02/20/02)
  2. ////////////////////////////////////////////////////////////////////////
  3. // Last Mod: 02/11/01
  4. ////////////////////////////////////////////////////////////////////////
  5. // File: movement.wdl
  6. //        WDL prefabs for entity movement
  7. ////////////////////////////////////////////////////////////////////////
  8.  
  9. ////////////////////////////////////////////////////////////////////////
  10. //
  11. ////////////////////////////////////////////////////////////////////////
  12.  
  13.  
  14. //@ Defines
  15. // Change them by re-defining them in your main wdl script
  16. // BEFORE the include, and adding DEFINE MOVE_DEFS;
  17. IFNDEF MOVE_DEFS;
  18.     SOUND  thud,<tap.wav>;
  19.     SOUND  robo_thud,<tap.wav>;  //??
  20.     SOUND  splash,<splash.wav>;
  21.     DEFINE shadowsprite,<shadow.pcx>;
  22.     DEFINE shadowflat,<shadflat.pcx>;
  23.     DEFINE DEFAULT_WALK,13.040;
  24.     DEFINE DEFAULT_RUN,5.060;
  25. ENDIF;
  26.  
  27.  
  28. ////////////////////////////////////////////////////////////////////////
  29. // User modifiable global skill definitions
  30. // Duplicate them in your wdl script AFTER the include
  31. // to give them new values
  32. // NOTE: in most cases it is a good idea to make actor_scale == movement_scale
  33. var movement_scale = 1.00;  // used to scale the movement
  34. var actor_scale = 1.00;    // used to scale the size of actors
  35.  
  36. var gnd_fric = 0.5;        // ground friction
  37. var air_fric = 0.03;     // air friction
  38. var water_fric = 0.75;    // water friction
  39. var ang_fric = 0.6;        // angular friction
  40.  
  41. var gravity = 6;             // gravity force
  42. var elasticity = 0.1;     // of the floor
  43.  
  44. var slopefac = 2; // gravity on slopes, determines the max angle to climb
  45.  
  46. var strength[3] = 5,4,75;    // default ahead, side, jump strength   (25)
  47. var astrength[3] = 7,5,2;    // default pan, tilt, roll strength
  48.  
  49. var jump_height = 25;     // maximum jump height above ground
  50. var fall_time = 10;        // max fall time before health is reduced
  51. var duck_height = 25;    // distance to adjust my_height while ducking
  52.  
  53. var power_max = 1;         // maximum engine power for aircraft
  54.  
  55.  
  56. // values set in scan_floor
  57. var on_passable_;
  58. var in_passable_;
  59. var in_solid_;
  60.  
  61.  
  62.  
  63. ///////////////////////////////////////////////////////////////////////
  64. // Entity skill & flag definitions
  65. // some definitions here are also needed for ACTORS.WDL and WAR.WDL
  66. DEFINE _WALKFRAMES,SKILL1;    // non-zero for old style animation
  67. DEFINE _RUNFRAMES,SKILL2;
  68. DEFINE _ATTACKFRAMES,SKILL3;
  69. DEFINE _DIEFRAMES,SKILL4;
  70.  
  71. DEFINE _FORCE,SKILL5;        // determines speed
  72. DEFINE _ENTFORCE,SKILL5;
  73. DEFINE _BANKING,SKILL6;        // banking - for player only
  74. DEFINE _PENDOLINO,SKILL6;    // banking - for player only
  75. DEFINE _HITMODE,SKILL6;        // for actors
  76. DEFINE _MOVEMODE,SKILL7;
  77. DEFINE _FIREMODE,SKILL8;    // for actors
  78.  
  79.  
  80.  
  81. DEFINE __FALL,FLAG1;        // take damage from falls
  82.  
  83. DEFINE __WHEELS,FLAG2;    // block turns without moving
  84. DEFINE __SLOPES,FLAG3;    // adapt the tilt and roll angle to slopes
  85. DEFINE __JUMP,FLAG4;        // be able to jump
  86. DEFINE __BOB,FLAG5;       // head wave
  87. DEFINE __STRAFE,FLAG6;    // be able to move sidewards
  88. DEFINE __TRIGGER,FLAG7;    // be able to trigger doors automatically
  89.  
  90. DEFINE __DUCK, FLAG8;    // be able to duck
  91.  
  92. DEFINE __SOUND,FLAG8;    // internal flag
  93.  
  94. ///////////////////////////////////////////////////////////////////////
  95. DEFINE _HEALTH,SKILL9;
  96. DEFINE _ARMOR,SKILL10;
  97.  
  98. DEFINE _SPEED,SKILL11;        // speed
  99. DEFINE _SPEED_X,SKILL11;
  100. DEFINE _SPEED_Y,SKILL12;
  101. DEFINE _POWER,SKILL12;        // engine power for aircraft models
  102. DEFINE _SPEED_Z,SKILL13;
  103. DEFINE _ASPEED,SKILL14;        // angular speed
  104. DEFINE _ASPEED_PAN,SKILL14;
  105. DEFINE _ASPEED_TILT,SKILL15;
  106. DEFINE _ASPEED_ROLL,SKILL16;
  107.  
  108. // for actor entities, and for doors and platforms
  109. DEFINE _TARGET_X,SKILL17;
  110. DEFINE _TARGET_Y,SKILL18;
  111. DEFINE _TARGET_Z,SKILL19;
  112. DEFINE _TARGET_PAN,SKILL20;
  113. DEFINE _TARGET_TILT,SKILL21;
  114. DEFINE _TARGET_ROLL,SKILL22;
  115.  
  116. // for player entities
  117. DEFINE _FORCE_X,SKILL17;
  118. DEFINE _FORCE_Y,SKILL18;
  119. DEFINE _FORCE_Z,SKILL19;
  120. DEFINE _AFORCE_PAN,SKILL20;
  121. DEFINE _AFORCE_TILT,SKILL21;
  122. DEFINE _AFORCE_ROLL,SKILL22;
  123.  
  124. DEFINE _WALKSOUND,SKILL23;    // walking sound
  125. DEFINE _SIGNAL,SKILL24;        // communication for actions or client->server
  126. DEFINE _COUNTER,SKILL25;    // internal counter
  127. DEFINE _STATE,SKILL26;        // the state it is in (walk, attack, escape etc.)
  128.  
  129. DEFINE _ANIMDIST,SKILL28;    // time for standing, jumping, and ducking animations
  130.  
  131. DEFINE _JUMPTARGET,SKILL29;// target height to jump to
  132.  
  133. DEFINE _TYPE,SKILL30;        // the type of the entity - door, key, etc.
  134.  
  135. DEFINE _FALLTIME,SKILL31;    // amount of time spent falling
  136.  
  137. // Skills up to 32 are reserved for future template actions
  138. // Skills 33-40 can be used freely
  139.  
  140. //@@ Vector Vars
  141. // Force Vars
  142. var force[3];        // cartesian force, entity coordinates
  143. var absforce[3];    // cartesian force, world coordinates
  144. var aforce[3];        // angular force
  145.  
  146. //@@ Distance Vars
  147. var abspeed[3] = 0,0,0;    // cartesian speed, world coordinates
  148. var dist[3];
  149. var absdist[3];    // distances used for MOVE
  150.  
  151. //@@ Camera Vars
  152. var person_3rd    = 0;        // 0: 1st person mode; 0.5: 3rd person mode
  153.  
  154. var eye_height_up = 0.8;    // eye position factor for walking, driving
  155. var eye_height_swim = 0.7;    // first person camera offset for swimming
  156. var eye_height_duck = 0.8; // first person camera offset for ducking (7/19/00: same as eye_height_up since ducking is controlled by my_height)
  157.  
  158. //@@ Multiplayer Vars
  159. var client_moving = 0;     // multiplayer mode
  160.  
  161.  
  162. //@@ Mics Vars
  163. var p[3];
  164. var friction;
  165. var limit[3];
  166. var covered_dist;
  167. var anim_dist;
  168.  
  169. var head_angle[3] = 0,0,0;    // separated from other values
  170. var headwave = 0;
  171. var walkwave = 0;
  172. var my_dist;            // distance for actor anim
  173. var player_dist;        // distance for head bobbing
  174. var scan_sector;
  175. var my_height;
  176. var my_height_passable;    // height above passable surface (valid only if on passable surface)
  177. var my_floornormal[3];
  178. var my_floorspeed[3];
  179. var temp_cdist[3] = 120,0,0;   // current camera distance in 3rd p view
  180. //-var debugskill;
  181.  
  182. // temp values used to replace sonar with trace (DCP-11/9/00)
  183. var vecFrom[3];
  184. var vecTo[3];
  185.  
  186. var temp2[3];    // another temp var
  187.  
  188.  
  189. //SYNONYM player { TYPE ENTITY; }
  190. //SYNONYM temp_ent { TYPE ENTITY; }
  191. //SYNONYM carry { TYPE ACTION; }
  192. entity*    player;    // pointer to player entity
  193. entity*    temp_ent;
  194. action*    carry;
  195.  
  196. DEFINE _MODE_WALKING,1;
  197. DEFINE _MODE_DRIVING,2;
  198. DEFINE _MODE_SWIMMING,3;
  199. DEFINE _MODE_DIVING,4;
  200. DEFINE _MODE_WADING,5;
  201. DEFINE _MODE_HELICOPTER,6;    // very primitive helicopter mode
  202. DEFINE _MODE_ROCKETEER,7;
  203. DEFINE _MODE_DUCKING,8;        // ducking
  204. DEFINE _MODE_JUMPING,9;        // jumping
  205. DEFINE _MODE_CRAWLING,10;    // crawling
  206. DEFINE _MODE_TRANSITION,14;
  207. DEFINE _MODE_STILL,15;
  208.  
  209. DEFINE _MODE_PLANE,16;
  210. DEFINE _MODE_CHOPPER,17;
  211.  
  212.  
  213. // modes 20 and above are handled by a different wdl
  214. DEFINE _MODE_ATTACK,20;
  215.  
  216. DEFINE _SOUND_WALKER,1;
  217. DEFINE _SOUND_ROBOT,2;
  218.  
  219. DEFINE _TYPE_PLAYER,1;
  220. DEFINE _TYPE_ACTOR,2;
  221. DEFINE _TYPE_FOE,3;
  222. DEFINE _TYPE_DOOR,10;
  223. DEFINE _TYPE_GATE,11;
  224. DEFINE _TYPE_ELEVATOR,12;
  225. DEFINE _TYPE_GUN,20;
  226. DEFINE _TYPE_AMMO,21;
  227. DEFINE _TYPE_ARMOR,22;
  228. DEFINE _TYPE_HEALTH,23;
  229.  
  230. DEFINE _FOG_UNDERWATER,2;    // fog color 2 is used for underwater fog
  231.  
  232. SOUND beep_sound,<beep.wav>;
  233. //SYNONYM debugsyn { TYPE ENTITY; }
  234.  
  235.  
  236.  
  237. /////////////////////////////////////////////////////////////////////////
  238. //@ MISC movement functions
  239.  
  240.  
  241. /////////////////////////////////////////////////////////////////////////
  242. // Desc: player tips over, can be used for death
  243. function player_tip()
  244. {
  245.     MY._MOVEMODE = 0;    // suspend normal movement action
  246.     eye_height_up.Z = eye_height_up;    // store original eye height
  247.     while(MY.ROLL < 80)
  248.     {
  249.         MY.ROLL += 0 * TIME;
  250.         MY.TILT += 0 * TIME;
  251.         if(eye_height_up > 0.15)
  252.         {
  253.             eye_height_up -= 0 * TIME;
  254.         }
  255.  
  256.         if(client_moving==0) { move_view(); }
  257.         wait(1);
  258.     }
  259.  
  260.     MY.ROLL = 80;
  261.     MY.TILT = 20;
  262.     eye_height_up = eye_height_up.Z;    // restore original eye height
  263. }
  264.  
  265.  
  266.  
  267. ////////////////////////////////////////////////////////////////////////
  268. // Desc: event action to indicate any event by resetting the event flag
  269. //
  270. function _setback()
  271. {
  272.     if(EVENT_TYPE == EVENT_BLOCK) { MY.ENABLE_BLOCK = OFF; }
  273.     if(EVENT_TYPE == EVENT_ENTITY) { MY.ENABLE_ENTITY = OFF; }
  274.     if(EVENT_TYPE == EVENT_STUCK) { MY.ENABLE_STUCK = OFF; }
  275.  
  276.     if(EVENT_TYPE == EVENT_PUSH) { MY.ENABLE_PUSH = OFF; }
  277.     if(EVENT_TYPE == EVENT_IMPACT) { MY.ENABLE_IMPACT = OFF; }
  278.  
  279.     if(EVENT_TYPE == EVENT_DETECT) { MY.ENABLE_DETECT = OFF; }
  280.     if(EVENT_TYPE == EVENT_SCAN) { MY.ENABLE_SCAN = OFF; }
  281.     if(EVENT_TYPE == EVENT_SHOOT) { MY.ENABLE_SHOOT = OFF; }
  282.     if(EVENT_TYPE == EVENT_TRIGGER) { MY.ENABLE_TRIGGER = OFF; }
  283.  
  284.     if(EVENT_TYPE == EVENT_TOUCH) { MY.ENABLE_TOUCH = OFF; }
  285.     if(EVENT_TYPE == EVENT_RELEASE) { MY.ENABLE_RELEASE = OFF; }
  286.     if(EVENT_TYPE == EVENT_CLICK) { MY.ENABLE_CLICK = OFF; }
  287. }
  288.  
  289.  
  290.  
  291. // Mod Date: 6/9/00 Doug Poston
  292. //                changed to function
  293. function _beep() { BEEP; }
  294.  
  295. // Desc: play some kinds of foot sound
  296. //
  297. function _play_walksound()
  298. {
  299.     if((ME == player) && (person_3rd == 0)) { return; }    // don't play entity sounds for 1st person player
  300.     if(MY._WALKSOUND == _SOUND_WALKER) { play_entsound(ME,thud,60); }
  301.     if(MY._WALKSOUND == _SOUND_ROBOT) { play_entsound(ME,robo_thud,60); }
  302. }
  303.  
  304.  
  305. // Desc: test code. make object passable and remove after 128 ticks
  306. function _test_arrow()
  307. {
  308.     MY.PASSABLE = ON;
  309.     MY.SCALE_X = 0.5;
  310.     MY.SCALE_Y = 0.5;
  311.     waitt(128);
  312.     remove(ME);
  313. }
  314.  
  315.  
  316.  
  317.  
  318. // INCLUDED CODE (originally part of movement.wdl
  319. include <move.wdl>;
  320. include <camera.wdl>;    // handle camera movement
  321. include <animate.wdl>;  // handle animation
  322. include <input.wdl>;    // handle user input (mouse, keyboard, joystick, ..)
  323.